

		<link rel="stylesheet" href="__CSS__uniform.css" />
		<link rel="stylesheet" href="__CSS__select2.css" />
		<link rel="stylesheet" href="__CSS__jquery-ui.min.css" />
			
			<script src="__JS__jquery.min.js"></script>
            <script src="__JS__bootstrap.min.js"></script>
            <script src="__JS__jquery.uniform.js"></script>
            <script src="__JS__select2.min.js"></script>
            <script src="__JS__unicorn.js"></script>
            <script src="__JS__unicorn.tables.js"></script>
			<script src="__JS__jquery-ui.min.js"></script>
				


<div id="content">
	<div id="content-header">
		<h1>Tables</h1>
		<div class="btn-group">
			<a class="btn btn-large tip-bottom" title="Manage Files"><i class="icon-file"></i></a>
			<a class="btn btn-large tip-bottom" title="Manage Users"><i class="icon-user"></i></a>
			<a class="btn btn-large tip-bottom" title="Manage Comments"><i class="icon-comment"></i><span class="label label-important">5</span></a>
			<a class="btn btn-large tip-bottom" title="Manage Orders"><i class="icon-shopping-cart"></i></a>
		</div>
	</div>
	<div id="breadcrumb">
		<a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a>
		<a href="#" class="current">Tables</a>
	</div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
				<button onclick="addCate();" class="btn btn-danger btn-large">添加属性</button>						
			<div class="widget-box">
				<div class="widget-title">
					<h5>属性列表</h5>
				</div>
				<div class="widget-content nopadding">
					<div role="grid" class="dataTables_wrapper" id="DataTables_Table_0_wrapper">
					<table class="table table-bordered data-table dataTable" id="DataTables_Table_0">
						<thead>
						<tr>
						<th>属性ID</th>
						<th>属性名</th>
						<th>上级属性</th>
						<th>操作</th>
						</tr>
						</thead>
						<tbody>
						<foreach name="cateArray" key="key" item="values">
							<tr class="gradeX">
							<td>{$values['id']}</td>
							<td>{$values['brandName']}{$values['name']}</td>
							<td>{$values['parent_id']}</td>
							<td class="center">
								<button onclick="cateEdit('{$values['id']}','{$values['name']}',{$values['parent_id']})" id="edit" class="btn btn-primary"><i class="icon-pencil icon-white"></i> 修改</button>
								<button onclick="catedel({$values['id']});" class="btn btn-danger"><i class="icon-remove icon-white"></i> 删除</button>
									</td>
									</tr>
								</foreach>
								</tbody>
							</table>
							</div>
					</div>
				</div>
			</div>
		
		
<form id="dailog"  style="display:none;">
  <fieldset>
    <input type="hidden" name="cateid" id="cateid" value=""/>	      
    <label for="catename">属性名：</label>
    <input type="text" name="catename" id="catename" value="" class="text ui-widget-content ui-corner-all">
    <label for="catepid">上级ID</label>
    <select id="catepid" name="catepid">
    		<option>顶级属性</option>
    		<foreach name="cateArray" item="values">
    			<option value="{$values['id']}">{$values['cateName']}{$values['name']}</option>
    		</foreach>
    </select>
  </fieldset>
</form>


<div id="alerts"></div>


<script type="text/javascript">

function catedel(cateid){
		$.get("__CONTROLLER__/propertu.html?do=delete",
				{"cateid":cateid},
				function(data){
					alerts("删除成功","属性删除成功");

		});
}
function cateEdit(cateId,cateName,catepid)
	{
		$("#dailog").attr("title","修改属性");
		$("#cateid").val(cateId);
		$("#catename").val(cateName);
		$("#catepid").val(catepid);
		dailog=$("#dailog").dialog({
		      autoOpen: true,
		      height: 300,
		      width: 350,
		      cateName:'cateName',
		      buttons: {
		        "修改":editCate,
		        "取消": function() {
		         	dailog.dialog( "close");
		        },
		      },
		      close: function() {
		        $("#dailog")[0].reset();
		        //allFields.removeClass( "ui-state-error" );
		      }
		  });
	}	
	function editCate(){
		cateName=$("#catename").val();
		cateId=$("#cateid").val();
		catepid=$("#catepid").val();
		if(cateName=='')
		{
		  alerts("属性名不能为空","属性名不能为空");
		  return ;
		}
		$.post("__CONTROLLER__/propertu.html?do=update",
			  {"id":cateId,"name":cateName,"parent_id":catepid},
			  function(data){
				  dailog.dialog( "close");
				  alerts("修改成功","属性添加成功");
			  },
			  "json");
	}


	
	function addCate()
	{
		$("#dailog")[0].reset();
		$("#dailog").attr("title","添加属性");
		dailog=$("#dailog").dialog({
		      autoOpen: true,
		      height: 300,
		      width: 350,
		      cateName:'cateName',
		      buttons: {
		        "增加":doAddcate,
		        "取消": function() {
		         	dailog.dialog( "close");
		        },
		      },
		      close: function() {
			        $("#dailog")[0].reset();
		        //allFields.removeClass( "ui-state-error" );
		      }
		  });
	}
	function doAddcate(){
		cateName=$("#catename").val();
		catepid=$("#catepid").val();
		if(cateName=='')
			{
			  alerts("属性名不能为空","属性名不能为空");
			  return ;
			}
		
		$.post("__CONTROLLER__/propertu.html?do=add",
			  {"name":cateName,"parent_id":catepid},
			  function(data){
				  dailog.dialog( "close");
				  alerts("添加成功","属性添加成功");
			  },
			"json");
	}

	function  alerts(title,message){
		$("#alerts").attr("title",title);
		$("#alerts").html("<b style='color:red;'>"+message+"</b>");
		dailog2=$("#alerts").dialog({buttons: {
	        "确定": function() {
			 	window.location.reload();
				dailog2.dialog( "close");
	        },
	      
	      }}); 
		
	}

</script>
				
			</div>
		</div>
            
           